package com.rc.evcharger.redis;

import com.rc.evcharger.common.enums.DataEnum;
import com.rc.evcharger.common.redis.RedisDao;
import com.rc.evcharger.common.utils.DataUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigDecimal;

/**
 * Create by Yang on 2018/12/25
 */
@Service
public class RedChargeDataServiceImpl implements RedChargeDataService {

    @Autowired
    private RedisDao redisDao;

    private static RedChargeDataService proxy;

    @PostConstruct
    public void init() {
        proxy = this;
    }

    /**
     * 执行批量删除KEY
     *
     * @param elcePileRtua
     * @param elecGunNum
     * @param orderNum
     */
    @Override
    public void clearAllDate(String elcePileRtua, String elecGunNum, String orderNum) {
        try {
            String[] s = {elcePileRtua, elecGunNum, orderNum};
            Method[] methods = this.getClass().getMethods();
            for (Method method : methods) {
                String methodName = method.getName();
                if (methodName.startsWith("remove")) {
                    //二选一都可以
//                    Method tenantCode = this.getClass().getMethod(methodName, String.class,String.class,String.class);
//                    method.invoke(this, (Object[]) s);
                    Method tenantCode = proxy.getClass().getMethod(methodName, String.class, String.class, String.class);
                    method.invoke(proxy, (Object[]) s);
                }
            }
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }

    /**
     * 获取枪状态
     **/
    @Override
    public String getGunStatus(String rtua, String gunNum) {
        String gunStatuskey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[14][0]);
        return redisDao.getRedis(gunStatuskey);
    }

    /**
     * 枪状态不需要删除，
     * 永久保留
     */
//    @Override
//    public void removeGunStatus(String rtua, String gunNum,String orderNum) {
//        String gunStatuskey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[14][0]);
//        redisDao.deleteSession(gunStatuskey);
//    }

    /**
     * 存枪状态
     **/
    @Override
    public void putGunStatus(String rtua, String gunNum, Object value) {
        String gunStatuskey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[14][0]);
        redisDao.putRedis(gunStatuskey, String.valueOf(value));
    }

    /**
     * 获取上报时间
     **/
    @Override
    public String getChargeReportTime(String rtua, String gunNum, String orderNum) {
        String chargeReportTimeKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[22][0], orderNum);
        return redisDao.getRedis(chargeReportTimeKey);
    }

    @Override
    public void removeChargeReportTime(String rtua, String gunNum, String orderNum) {
        String gunStatuskey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[22][0], orderNum);
        redisDao.deleteSession(gunStatuskey);
    }

    /**
     * 存上报时间
     **/
    @Override
    public void putChargeReportTime(String rtua, String gunNum, String orderNum, Object value) {
        String chargeReportTimeKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[22][0], orderNum);
        redisDao.putRedis(chargeReportTimeKey, String.valueOf(value));
    }

    /**
     * 获取电量
     **/
    @Override
    public BigDecimal getPower(String rtua, String gunNum, String orderNum) {
        String powerKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[12][0], orderNum);
        String value = redisDao.getRedis(powerKey);
        return (value == null ? BigDecimal.ZERO : new BigDecimal(value));
    }

    @Override
    public void removePower(String rtua, String gunNum, String orderNum) {
        String powerKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[12][0], orderNum);
        redisDao.deleteSession(powerKey);
    }

    /**
     * 存电量
     **/
    @Override
    public void putPower(String rtua, String gunNum, String orderNum, Object value) {
        String powerKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[12][0], orderNum);
        redisDao.putRedis(powerKey, String.valueOf(value));
    }

    /**
     * 获取电流
     **/
    @Override
    public BigDecimal getElec(String rtua, String gunNum, String orderNum) {
        String elecKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[10][0], orderNum);
        String value = redisDao.getRedis(elecKey);
        return (value == null ? BigDecimal.ZERO : new BigDecimal(value));
    }

    @Override
    public void removeElec(String rtua, String gunNum, String orderNum) {
        String elecKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[10][0], orderNum);
        redisDao.deleteSession(elecKey);
    }

    /**
     * 存电流
     **/
    @Override
    public void putElec(String rtua, String gunNum, String orderNum, Object value) {
        String elecKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[10][0], orderNum);
        redisDao.putRedis(elecKey, String.valueOf(value));
    }

    /**
     * 获取电压
     **/
    @Override
    public BigDecimal getVol(String rtua, String gunNum, String orderNum) {
        String volKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[9][0], orderNum);
        String value = redisDao.getRedis(volKey);
        return (value == null ? BigDecimal.ZERO : new BigDecimal(value));
    }

    @Override
    public void removeVol(String rtua, String gunNum, String orderNum) {
        String volKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[9][0], orderNum);
        redisDao.deleteSession(volKey);
    }

    /**
     * 存电压
     **/
    @Override
    public void putVol(String rtua, String gunNum, String orderNum, Object value) {
        String volKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[9][0], orderNum);
        redisDao.putRedis(volKey, String.valueOf(value));
    }

    /**
     * 存开始soc
     **/
    @Override
    public BigDecimal getBeginSoc(String rtua, String gunNum, String orderNum) {
        String volKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.DEMAND_ELEC.getCode(), orderNum);
        String value = redisDao.getRedis(volKey);
        return (value == null ? BigDecimal.ZERO : new BigDecimal(value));
    }

    /**
     * 删开始soc
     **/
    @Override
    public void removeBeginSoc(String rtua, String gunNum, String orderNum) {
        String volKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.DEMAND_ELEC.getCode(), orderNum);
        redisDao.deleteSession(volKey);
    }

    /**
     * 取开始soc
     **/
    @Override
    public void putBeginSoc(String rtua, String gunNum, String orderNum, Object value) {
        String volKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.DEMAND_ELEC.getCode(), orderNum);
        redisDao.putRedis(volKey, String.valueOf(value));
    }

    /**
     * 获取soc
     **/
    @Override
    public BigDecimal getSoc(String rtua, String gunNum, String orderNum) {
        String socKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[3][0], orderNum);
        String value = redisDao.getRedis(socKey);
        return (value == null ? BigDecimal.ZERO : new BigDecimal(value));
    }

    @Override
    public void removeSoc(String rtua, String gunNum, String orderNum) {
        String socKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[3][0], orderNum);
        redisDao.deleteSession(socKey);
    }

    /**
     * 存soc
     **/
    @Override
    public void putSoc(String rtua, String gunNum, String orderNum, Object value) {
        String socKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[3][0], orderNum);
        redisDao.putRedis(socKey, String.valueOf(value));
    }

    /**
     * 获取电价ID
     **/
    @Override
    public String getEpgPriceId(String rtua, String gunNum, String orderNum) {
        String epgPriceIdKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[24][0], orderNum);
        return redisDao.getRedis(epgPriceIdKey);
    }

    @Override
    public void removeEpgPriceId(String rtua, String gunNum, String orderNum) {
        String epgPriceIdKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[24][0], orderNum);
        redisDao.deleteSession(epgPriceIdKey);
    }

    /**
     * 存电价ID
     **/
    @Override
    public void putEpgPriceId(String rtua, String gunNum, String orderNum, Object value) {
        String epgPriceIdKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[24][0], orderNum);
        redisDao.putRedis(epgPriceIdKey, String.valueOf(value));
    }

    /**
     * 获取订单单价
     * @param rtua
     * @param gunNum
     * @param orderNum
     * @return
     */
    @Override
    public String getOrderInfoPrices(String rtua, String gunNum, String orderNum) {
        String baseAmountKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.ORDER_INFO_PRICES.getCode(), orderNum);
        return redisDao.getRedis(baseAmountKey);
    }

    @Override
    public void removeOrderInfoPrices(String rtua, String gunNum, String orderNum) {
        String epgPriceIdKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.ORDER_INFO_PRICES.getCode(), orderNum);
        redisDao.deleteSession(epgPriceIdKey);
    }

    @Override
    public void putOrderInfoPrices(String rtua, String gunNum, String orderNum, Object value) {
        String epgPriceIdKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.ORDER_INFO_PRICES.getCode(), orderNum);
        redisDao.putRedis(epgPriceIdKey, String.valueOf(value));
    }

    @Override
    public String getOrderInfoCurrentPrice(String rtua, String gunNum, String orderNum) {
        String baseAmountKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.ORDER_INFO_CURRENT_PRICES.getCode(), orderNum);
        return redisDao.getRedis(baseAmountKey);
    }

    @Override
    public void removeOrderInfoCurrentPrice(String rtua, String gunNum, String orderNum) {
        String epgPriceIdKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.ORDER_INFO_CURRENT_PRICES.getCode(), orderNum);
        redisDao.deleteSession(epgPriceIdKey);
    }

    @Override
    public void putOrderInfoCurrentPrice(String rtua, String gunNum, String orderNum, Object value) {
        String epgPriceIdKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.ORDER_INFO_CURRENT_PRICES.getCode(), orderNum);
        redisDao.putRedis(epgPriceIdKey, String.valueOf(value));
    }

    /**
     * 获取基本电费
     **/
    @Override
    public BigDecimal getBaseAmount(String rtua, String gunNum, String orderNum) {
        String baseAmountKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[23][0], orderNum);
        String value = redisDao.getRedis(baseAmountKey);
        return (value == null ? new BigDecimal(0) : new BigDecimal(value));
    }

    @Override
    public void removeBaseAmount(String rtua, String gunNum, String orderNum) {
        String baseAmountKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[23][0], orderNum);
        redisDao.deleteSession(baseAmountKey);
    }

    /**
     * 存基本电费
     **/
    @Override
    public void putBaseAmount(String rtua, String gunNum, String orderNum, Object value) {
        String baseAmountKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[23][0], orderNum);
        redisDao.putRedis(baseAmountKey, String.valueOf(value));
    }

    /**
     * 获取服务费
     **/
    @Override
    public BigDecimal getServiceAmount(String rtua, String gunNum, String orderNum) {
        String serviceAmountKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[26][0], orderNum);
        String value = redisDao.getRedis(serviceAmountKey);
        return (value == null ? new BigDecimal(0) : new BigDecimal(value));
    }

    @Override
    public void removeServiceAmount(String rtua, String gunNum, String orderNum) {
        String serviceAmountKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[26][0], orderNum);
        redisDao.deleteSession(serviceAmountKey);
    }

    /**
     * 存服务费
     **/
    @Override
    public void putServiceAmount(String rtua, String gunNum, String orderNum, Object value) {
        String serviceAmountKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[26][0], orderNum);
        redisDao.putRedis(serviceAmountKey, String.valueOf(value));
    }

    /**
     * 获取总电价
     **/
    @Override
    public BigDecimal getAmount(String rtua, String gunNum, String orderNum) {
        String AmountKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[13][0], orderNum);
        String value = redisDao.getRedis(AmountKey);
        return (value == null ? new BigDecimal(0) : new BigDecimal(value));
    }

    @Override
    public void removeAmount(String rtua, String gunNum, String orderNum) {
        String AmountKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[13][0], orderNum);
        redisDao.deleteSession(AmountKey);
    }

    /**
     * 存总电价
     **/
    @Override
    public void putAmount(String rtua, String gunNum, String orderNum, Object value) {
        String AmountKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[13][0], orderNum);
        redisDao.putRedis(AmountKey, String.valueOf(value));
    }

    //反向互联互通调整价
    @Override
    public BigDecimal getServiceAdjustAmount(String rtua, String gunNum, String orderNum) {
        String serviceAdjustAmountKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.SERVICE_ADJUST_AMOUNT.getCode(), orderNum);
        String value = redisDao.getRedis(serviceAdjustAmountKey);
        return (value == null ? new BigDecimal(0) : new BigDecimal(value));
    }

    @Override
    public void removeServiceAdjustAmount(String rtua, String gunNum, String orderNum) {
        String serviceAdjustAmountKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.SERVICE_ADJUST_AMOUNT.getCode(), orderNum);
        redisDao.deleteSession(serviceAdjustAmountKey);
    }

    @Override
    public void putServiceAdjustAmount(String rtua, String gunNum, String orderNum, Object value) {
        String serviceAdjustAmountKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.SERVICE_ADJUST_AMOUNT.getCode(), orderNum);
        redisDao.putRedis(serviceAdjustAmountKey, String.valueOf(value));
    }

    @Override
    public BigDecimal getActBaseAmount(String rtua, String gunNum, String orderNum) {
        String baseAmountKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.ACT_BASE_AMOUNT.getCode(), orderNum);
        String value = redisDao.getRedis(baseAmountKey);
        return (value == null ? new BigDecimal(0) : new BigDecimal(value));
    }

    @Override
    public void removeActBaseAmount(String rtua, String gunNum, String orderNum) {
        String AmountKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.ACT_BASE_AMOUNT.getCode(), orderNum);
        redisDao.deleteSession(AmountKey);
    }

    @Override
    public void putActBaseAmount(String rtua, String gunNum, String orderNum, Object value) {
        String AmountKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.ACT_BASE_AMOUNT.getCode(), orderNum);
        redisDao.putRedis(AmountKey, String.valueOf(value));
    }

    @Override
    public BigDecimal getActServiceAmount(String rtua, String gunNum, String orderNum) {
        String baseAmountKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.ACT_SERVICE_AMOUNT.getCode(), orderNum);
        String value = redisDao.getRedis(baseAmountKey);
        return (value == null ? new BigDecimal(0) : new BigDecimal(value));
    }

    @Override
    public void removeActServiceAmount(String rtua, String gunNum, String orderNum) {
        String AmountKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.ACT_SERVICE_AMOUNT.getCode(), orderNum);
        redisDao.deleteSession(AmountKey);
    }

    @Override
    public void putActServiceAmount(String rtua, String gunNum, String orderNum, Object value) {
        String AmountKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.ACT_SERVICE_AMOUNT.getCode(), orderNum);
        redisDao.putRedis(AmountKey, String.valueOf(value));
    }

    @Override
    public BigDecimal getActAmount(String rtua, String gunNum, String orderNum) {
        String baseAmountKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.ACT_TOTAL_AMOUNT.getCode(), orderNum);
        String value = redisDao.getRedis(baseAmountKey);
        return (value == null ? new BigDecimal(0) : new BigDecimal(value));
    }

    @Override
    public void removeActAmount(String rtua, String gunNum, String orderNum) {
        String AmountKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.ACT_TOTAL_AMOUNT.getCode(), orderNum);
        redisDao.deleteSession(AmountKey);
    }

    @Override
    public void putActAmount(String rtua, String gunNum, String orderNum, Object value) {
        String AmountKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.ACT_TOTAL_AMOUNT.getCode(), orderNum);
        redisDao.putRedis(AmountKey, String.valueOf(value));
    }

    /**
     * 取充电返回结果
     **/
    @Override
    public String getChargeResult(String rtua, String gunNum, String orderNum) {
        String priceKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[21][0], orderNum);
        return redisDao.getRedis(priceKey);
    }

    @Override
    public void removeChargeResult(String rtua, String gunNum, String orderNum) {
        String priceKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[21][0], orderNum);
        redisDao.deleteSession(priceKey);
    }

    /**
     * 存充电返回结果
     * 0.发送指令成功  1.发送指令失败   2.启动成功    3.启动失败  4.停止成功  5.停止失败
     **/
    @Override
    public void putChargeResult(String rtua, String gunNum, String memberId, Object value) {
        String priceKey = DataUtil.getCurrDataKey(rtua, gunNum, (String) DataUtil.dataCodes[21][0], memberId);
        redisDao.putRedis(priceKey, String.valueOf(value));
    }

    /**
     * 取枪约束的结果
     *
     * @param rtua
     * @param gunNum
     * @return
     */
    @Override
    public String getCheckPileTime(String rtua, String gunNum) {
        String checkPileTimeKey = DataUtil.getCheckPileTime(rtua, gunNum);
        return redisDao.getRedis(checkPileTimeKey);
    }

    /**
     * 存枪约束的结果
     *
     * @param rtua
     * @param gunNum
     * @param value
     */
    @Override
    public void putCheckPileTime(String rtua, String gunNum, Object value) {
        String checkPileTimeKey = DataUtil.getCheckPileTime(rtua, gunNum);
        redisDao.putRedis(checkPileTimeKey, String.valueOf(value));
    }

    /**
     * @param rtua
     * @param gunNum
     * @param nullValue 不能去掉，否则反射删除会报错
     */
    @Override
    public void removeCheckPileTime(String rtua, String gunNum, String nullValue) {
        String checkPileTimeKey = DataUtil.getCheckPileTime(rtua, gunNum);
        redisDao.deleteSession(checkPileTimeKey);
    }

    /**
     * 获取停止方式
     *
     * @param rtua
     * @param gunNum
     * @param orderNum
     * @return
     */
    @Override
    public String getStopMode(String rtua, String gunNum, String orderNum) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.STOP_NORMAL.getCode(), orderNum);
        return redisDao.getRedis(stopReasonKey);
    }

    @Override
    public void removeStopMode(String rtua, String gunNum, String orderNum) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.STOP_NORMAL.getCode(), orderNum);
        redisDao.deleteSession(stopReasonKey);
    }

    @Override
    public void putStopMode(String rtua, String gunNum, String orderNum, Object value) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.STOP_NORMAL.getCode(), orderNum);
        redisDao.putRedis(stopReasonKey, String.valueOf(value));
    }

    /**
     * 桩停止原因
     * PILE_STOP_NORMAL
     *
     * @param rtua
     * @param gunNum
     * @param orderNum
     * @return
     */
    @Override
    public String getPileStopMode(String rtua, String gunNum, String orderNum) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.PILE_STOP_NORMAL.getCode(), orderNum);
        return redisDao.getRedis(stopReasonKey);
    }

    @Override
    public void removePileStopMode(String rtua, String gunNum, String orderNum) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.PILE_STOP_NORMAL.getCode(), orderNum);
        redisDao.deleteSession(stopReasonKey);
    }

    @Override
    public void putPileStopMode(String rtua, String gunNum, String orderNum, Object value) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.PILE_STOP_NORMAL.getCode(), orderNum);
        redisDao.putRedis(stopReasonKey, String.valueOf(value));
    }

    /**
     * 得到最大电流
     *
     * @param rtua
     * @param gunNum
     * @param orderNum
     * @return
     */
    @Override
    public String getMaxElec(String rtua, String gunNum, String orderNum) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.MAX_ELEC.getCode(), orderNum);
        return redisDao.getRedis(stopReasonKey);
    }

    @Override
    public void removeMaxElec(String rtua, String gunNum, String orderNum) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.MAX_ELEC.getCode(), orderNum);
        redisDao.deleteSession(stopReasonKey);
    }

    @Override
    public void putMaxElec(String rtua, String gunNum, String orderNum, Object value) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.MAX_ELEC.getCode(), orderNum);
        redisDao.putRedis(stopReasonKey, String.valueOf(value));
    }

    /**
     * 得到最大电压
     *
     * @param rtua
     * @param gunNum
     * @param orderNum
     * @return
     */
    @Override
    public String getMaxVoltage(String rtua, String gunNum, String orderNum) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.MAX_VOLTAGE.getCode(), orderNum);
        return redisDao.getRedis(stopReasonKey);
    }

    @Override
    public void removeMaxVoltage(String rtua, String gunNum, String orderNum) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.MAX_VOLTAGE.getCode(), orderNum);
        redisDao.deleteSession(stopReasonKey);
    }

    @Override
    public void putMaxVoltage(String rtua, String gunNum, String orderNum, Object value) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.MAX_VOLTAGE.getCode(), orderNum);
        redisDao.putRedis(stopReasonKey, String.valueOf(value));
    }

    /**
     * 当前最高单体温度
     *
     * @param rtua
     * @param gunNum
     * @param orderNum
     * @return
     */
    @Override
    public String getTemperatureHigh(String rtua, String gunNum, String orderNum) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.TEMPERATURE_HIGH.getCode(), orderNum);
        return redisDao.getRedis(stopReasonKey);
    }

    @Override
    public void removeTemperatureHigh(String rtua, String gunNum, String orderNum) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.TEMPERATURE_HIGH.getCode(), orderNum);
        redisDao.deleteSession(stopReasonKey);
    }

    @Override
    public void putTemperatureHigh(String rtua, String gunNum, String orderNum, Object value) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.TEMPERATURE_HIGH.getCode(), orderNum);
        redisDao.putRedis(stopReasonKey, String.valueOf(value));
    }

    /**
     * 当前最底单体温度
     *
     * @param rtua
     * @param gunNum
     * @param orderNum
     * @return
     */
    @Override
    public String getTemperatureLow(String rtua, String gunNum, String orderNum) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.TEMPERATURE_LOW.getCode(), orderNum);
        return redisDao.getRedis(stopReasonKey);
    }

    @Override
    public void removeTemperatureLow(String rtua, String gunNum, String orderNum) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.TEMPERATURE_LOW.getCode(), orderNum);
        redisDao.deleteSession(stopReasonKey);
    }

    @Override
    public void putTemperatureLow(String rtua, String gunNum, String orderNum, Object value) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.TEMPERATURE_LOW.getCode(), orderNum);
        redisDao.putRedis(stopReasonKey, String.valueOf(value));
    }


    /**
     * 当前最高单体温度
     *
     * @param rtua
     * @param gunNum
     * @param orderNum
     * @return
     */
    @Override
    public String getTemperatureGun(String rtua, String gunNum, String orderNum) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.TEMPERATURE_GUN.getCode(), orderNum);
        return redisDao.getRedis(stopReasonKey);
    }

    @Override
    public void removeTemperatureGun(String rtua, String gunNum, String orderNum) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.TEMPERATURE_GUN.getCode(), orderNum);
        redisDao.deleteSession(stopReasonKey);
    }

    @Override
    public void putTemperatureGun(String rtua, String gunNum, String orderNum, Object value) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.TEMPERATURE_GUN.getCode(), orderNum);
        redisDao.putRedis(stopReasonKey, String.valueOf(value));
    }


    /**
     * 当前车辆需求电流
     *
     * @param rtua
     * @param gunNum
     * @param orderNum
     * @return
     */
    @Override
    public BigDecimal getDemandVoltage(String rtua, String gunNum, String orderNum) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.DEMAND_VOLTAGE.getCode(), orderNum);
        String value = redisDao.getRedis(stopReasonKey);
        return (value == null ? BigDecimal.ZERO : new BigDecimal(value));
    }

    @Override
    public void removeDemandVoltage(String rtua, String gunNum, String orderNum) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.DEMAND_VOLTAGE.getCode(), orderNum);
        redisDao.deleteSession(stopReasonKey);
    }

    @Override
    public void putDemandVoltage(String rtua, String gunNum, String orderNum, Object value) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.DEMAND_VOLTAGE.getCode(), orderNum);
        redisDao.putRedis(stopReasonKey, String.valueOf(value));
    }

    /**
     * 当前车辆需求电流
     *
     * @param rtua
     * @param gunNum
     * @param orderNum
     * @return
     */
    @Override
    public BigDecimal getDemandElec(String rtua, String gunNum, String orderNum) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.DEMAND_ELEC.getCode(), orderNum);
        String value = redisDao.getRedis(stopReasonKey);
        return (value == null ? BigDecimal.ZERO : new BigDecimal(value));
    }

    @Override
    public void removeDemandElec(String rtua, String gunNum, String orderNum) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.DEMAND_ELEC.getCode(), orderNum);
        redisDao.deleteSession(stopReasonKey);
    }

    @Override
    public void putDemandElec(String rtua, String gunNum, String orderNum, Object value) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.DEMAND_ELEC.getCode(), orderNum);
        redisDao.putRedis(stopReasonKey, String.valueOf(value));
    }


    @Override
    public void putPileApplicationName(String rtua, String gunNum, String temp, Object value) {
        String gunStatuskey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.PILE_APPLICATION_NAME.getCode());
        redisDao.putRedis(gunStatuskey, String.valueOf(value));
    }

    @Override
    public String getPileApplicationName(String rtua, String gunNum, String temp) {
        String chargeReportTimeKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.PILE_APPLICATION_NAME.getCode());
        return redisDao.getRedis(chargeReportTimeKey);
    }

    @Override
    public void removePileApplicationName(String rtua, String gunNum, String temp) {
        //String gunStatuskey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.PILE_APPLICATION_NAME.getCode());
        //redisDao.deleteSession(gunStatuskey);
    }

    @Override
    public void putOrderNum(String rtua, String gunNum, String orderNum, Object value) {
        String gunStatuskey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.ORDER_NUM_INFO.getCode(),orderNum);
        redisDao.putRedis(gunStatuskey, String.valueOf(value));
    }

    @Override
    public String getOrderNum(String rtua, String gunNum, String orderNum) {
        String chargeReportTimeKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.ORDER_NUM_INFO.getCode(),orderNum);
        return redisDao.getRedis(chargeReportTimeKey);
    }

    @Override
    public void removeOrderNum(String rtua, String gunNum, String orderNum) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.ORDER_NUM_INFO.getCode(), orderNum);
        redisDao.deleteSession(stopReasonKey);
    }

    @Override
    public void putRemainChargingTime(String rtua, String gunNum, String orderNum, Object value) {
        String gunStatuskey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.REMAIN_CHARGING_TIME.getCode(),orderNum);
        redisDao.putRedis(gunStatuskey, String.valueOf(value));
    }

    @Override
    public String getRemainChargingTime(String rtua, String gunNum, String orderNum) {
        String chargeReportTimeKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.REMAIN_CHARGING_TIME.getCode(),orderNum);
        return redisDao.getRedis(chargeReportTimeKey);
    }

    @Override
    public void removeRemainChargingTime(String rtua, String gunNum, String orderNum) {
        String stopReasonKey = DataUtil.getCurrDataKey(rtua, gunNum, DataEnum.REMAIN_CHARGING_TIME.getCode(), orderNum);
        redisDao.deleteSession(stopReasonKey);
    }

}
